package com.deng.api.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 分页通用格式
 * @param <T>
 */
@Data
@ApiModel
@NoArgsConstructor
@AllArgsConstructor
public class PageVO<T> {

    @ApiModelProperty("分页数据")
    private T content;
    @ApiModelProperty("分页总数量")
    private Long totalElements;

    public static PageVO toPageVO(IPage p){
        return new PageVO(p.getRecords(), p.getTotal());
    }

}
